home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tcl / dist / tclInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-21  |  31.6 KB  |  833 lines

  1. /*
  2.  * tclInt.h --
  3.  *
  4.  *    Declarations of things used internally by the Tcl interpreter.
  5.  *
  6.  * Copyright 1987-1991 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /user6/ouster/tcl/RCS/tclInt.h,v 1.69 92/06/21 14:09:23 ouster Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _TCLINT
  19. #define _TCLINT
  20.  
  21. /*
  22.  * Common include files needed by most of the Tcl source files are
  23.  * included here, so that system-dependent personalizations for the
  24.  * include files only have to be made in once place.  This results
  25.  * in a few extra includes, but greater modularity.  The order of
  26.  * the three groups of #includes is important.  For example, stdio.h
  27.  * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is
  28.  * needed by stdlib.h in some configurations.
  29.  */
  30.  
  31. #include <stdio.h>
  32.  
  33. #ifndef _TCL
  34. #include "tcl.h"
  35. #endif
  36. #ifndef _TCLHASH
  37. #include "tclHash.h"
  38. #endif
  39. #ifndef _REGEXP
  40. #include "regexp.h"
  41. #endif
  42.  
  43. /*
  44.  * Macro to use instead of "void" for arguments that must have
  45.  * type "void *" in ANSI C;  maps them to type "char *" in
  46.  * non-ANSI systems.  This macro may be used in some of the include
  47.  * files below, which is why it is defined here.
  48.  */
  49.  
  50. #ifndef VOID
  51. #   ifdef __STDC__
  52. #       define VOID void
  53. #   else
  54. #       define VOID char
  55. #   endif
  56. #endif
  57.  
  58. #include <ctype.h>
  59. #include <stdlib.h>
  60. #include <string.h>
  61. #include <varargs.h>
  62.  
  63. /*
  64.  * At present (12/91) not all stdlib.h implementations declare strtod.
  65.  * The declaration below is here to ensure that it's declared, so that
  66.  * the compiler won't take the default approach of assuming it returns
  67.  * an int.  There's no ANSI prototype for it because there would end
  68.  * up being too many conflicts with slightly-different prototypes.
  69.  */
  70.  
  71. extern double strtod();
  72.  
  73. /*
  74.  *----------------------------------------------------------------
  75.  * Data structures related to variables.   These are used primarily
  76.  * in tclVar.c
  77.  *----------------------------------------------------------------
  78.  */
  79.  
  80. /*
  81.  * The following structure defines a variable trace, which is used to
  82.  * invoke a specific C procedure whenever certain operations are performed
  83.  * on a variable.
  84.  */
  85.  
  86. typedef struct VarTrace {
  87.     Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given
  88.                  * by flags are performed on variable. */
  89.     ClientData clientData;    /* Argument to pass to proc. */
  90.     int flags;            /* What events the trace procedure is
  91.                  * interested in:  OR-ed combination of
  92.                  * TCL_TRACE_READS, TCL_TRACE_WRITES, and
  93.                  * TCL_TRACE_UNSETS. */
  94.     struct VarTrace *nextPtr;    /* Next in list of traces associated with
  95.                  * a particular variable. */
  96. } VarTrace;
  97.  
  98. /*
  99.  * When a variable trace is active (i.e. its associated procedure is
  100.  * executing), one of the following structures is linked into a list
  101.  * associated with the variable's interpreter.  The information in
  102.  * the structure is needed in order for Tcl to behave reasonably
  103.  * if traces are deleted while traces are active.
  104.  */
  105.  
  106. typedef struct ActiveVarTrace {
  107.     struct ActiveVarTrace *nextPtr;
  108.                 /* Next in list of all active variable
  109.                  * traces for the interpreter, or NULL
  110.                  * if no more. */
  111.     VarTrace *nextTracePtr;    /* Next trace to check after current
  112.                  * trace procedure returns;  if this
  113.                  * trace gets deleted, must update pointer
  114.                  * to avoid using free'd memory. */
  115. } ActiveVarTrace;
  116.  
  117. /*
  118.  * The following structure describes an enumerative search in progress on
  119.  * an array variable;  this are invoked with options to the "array"
  120.  * command.
  121.  */
  122.  
  123. typedef struct ArraySearch {
  124.     int id;            /* Integer id used to distinguish among
  125.                  * multiple concurrent searches for the
  126.                  * same array. */
  127.     struct Var *varPtr;        /* Pointer to array variable that's being
  128.                  * searched. */
  129.     Tcl_HashSearch search;    /* Info kept by the hash module about
  130.                  * progress through the array. */
  131.     Tcl_HashEntry *nextEntry;    /* Non-null means this is the next element
  132.                  * to be enumerated (it's leftover from
  133.                  * the Tcl_FirstHashEntry call or from
  134.                  * an "array anymore" command).  NULL
  135.                  * means must call Tcl_NextHashEntry
  136.                  * to get value to return. */
  137.     struct ArraySearch *nextPtr;/* Next in list of all active searches
  138.                  * for this variable, or NULL if this is
  139.                  * the last one. */
  140. } ArraySearch;
  141.  
  142. /*
  143.  * The structure below defines a variable, which associates a string name
  144.  * with a string value.  Pointers to these structures are kept as the
  145.  * values of hash table entries, and the name of each variable is stored
  146.  * in the hash entry.
  147.  */
  148.  
  149. typedef struct Var {
  150.     int valueLength;        /* Holds the number of non-null bytes
  151.                  * actually occupied by the variable's
  152.                  * current value in value.string (extra
  153.                  * space is sometimes left for expansion).
  154.                  * For array and global variables this is
  155.                  * meaningless. */
  156.     int valueSpace;        /* Total number of bytes of space allocated
  157.                  * at value. */
  158.     int upvarUses;        /* Counts number of times variable is
  159.                  * is referenced via global or upvar variables
  160.                  * (i.e. how many variables have "upvarPtr"
  161.                  * pointing to this variable).  Variable
  162.                  * can't be deleted until this count reaches
  163.                  * 0. */
  164.     VarTrace *tracePtr;        /* First in list of all traces set for this
  165.                  * variable. */
  166.     ArraySearch *searchPtr;    /* First in list of all searches active
  167.                  * for this variable, or NULL if none. */
  168.     int flags;            /* Miscellaneous bits of information about
  169.                  * variable.  See below for definitions. */
  170.     union {
  171.     char string[4];        /* String value of variable.  The actual
  172.                  * length of this field is given by the
  173.                  * valueSpace field above. */
  174.     Tcl_HashTable *tablePtr;/* For array variables, this points to
  175.                  * information about the hash table used
  176.                  * to implement the associative array. 
  177.                  * Points to malloc-ed data. */
  178.     Tcl_HashEntry *upvarPtr;
  179.                 /* If this is a global variable being
  180.                  * referred to in a procedure, or a variable
  181.                  * created by "upvar", this field points to
  182.                  * the hash table entry for the higher-level
  183.                  * variable. */
  184.     } value;            /* MUST BE LAST FIELD IN STRUCTURE!!! */
  185. } Var;
  186.  
  187. /*
  188.  * Flag bits for variables:
  189.  *
  190.  * VAR_ARRAY    -        1 means this is an array variable rather
  191.  *                than a scalar variable.
  192.  * VAR_UPVAR -             1 means this variable just contains a
  193.  *                pointer to another variable that has the
  194.  *                real value.  Variables like this come
  195.  *                about through the "upvar" and "global"
  196.  *                commands.
  197.  * VAR_UNDEFINED -        1 means that the variable is currently
  198.  *                undefined.  Undefined variables usually
  199.  *                go away completely, but if an undefined
  200.  *                variable has a trace on it, or if it is
  201.  *                a global variable being used by a procedure,
  202.  *                then it stays around even when undefined.
  203.  * VAR_ELEMENT_ACTIVE -        Used only in array variables;  1 means that
  204.  *                an element of the array is currently being
  205.  *                manipulated in some way, so that it isn't
  206.  *                safe to delete the whole array.
  207.  * VAR_TRACE_ACTIVE -        1 means that trace processing is currently
  208.  *                underway for a read or write access, so
  209.  *                new read or write accesses should not cause
  210.  *                trace procedures to be called and the
  211.  *                variable can't be deleted.
  212.  */
  213.  
  214. #define VAR_ARRAY        1
  215. #define VAR_UPVAR        2
  216. #define VAR_UNDEFINED        4
  217. #define VAR_ELEMENT_ACTIVE    0x10
  218. #define VAR_TRACE_ACTIVE    0x20
  219. #define VAR_SEARCHES_POSSIBLE    0x40
  220.  
  221. /*
  222.  *----------------------------------------------------------------
  223.  * Data structures related to procedures.   These are used primarily
  224.  * in tclProc.c
  225.  *----------------------------------------------------------------
  226.  */
  227.  
  228. /*
  229.  * The structure below defines an argument to a procedure, which
  230.  * consists of a name and an (optional) default value.
  231.  */
  232.  
  233. typedef struct Arg {
  234.     struct Arg *nextPtr;    /* Next argument for this procedure,
  235.                  * or NULL if this is the last argument. */
  236.     char *defValue;        /* Pointer to arg's default value, or NULL
  237.                  * if no default value. */
  238.     char name[4];        /* Name of argument starts here.  The name
  239.                  * is followed by space for the default,
  240.                  * if there is one.  The actual size of this
  241.                  * field will be as large as necessary to
  242.                  * hold both name and default value.  THIS
  243.                  * MUST BE THE LAST FIELD IN THE STRUCTURE!! */
  244. } Arg;
  245.  
  246. /*
  247.  * The structure below defines a command procedure, which consists of
  248.  * a collection of Tcl commands plus information about arguments and
  249.  * variables.
  250.  */
  251.  
  252. typedef struct Proc {
  253.     struct Interp *iPtr;    /* Interpreter for which this command
  254.                  * is defined. */
  255.     char *command;        /* Command that constitutes the body of
  256.                  * the procedure (dynamically allocated). */
  257.     Arg *argPtr;        /* Pointer to first of procedure's formal
  258.                  * arguments, or NULL if none. */
  259. } Proc;
  260.  
  261. /*
  262.  * The structure below defines a command trace.  This is used to allow Tcl
  263.  * clients to find out whenever a command is about to be executed.
  264.  */
  265.  
  266. typedef struct Trace {
  267.     int level;            /* Only trace commands at nesting level
  268.                  * less than or equal to this. */
  269.     Tcl_CmdTraceProc *proc;    /* Procedure to call to trace command. */
  270.     ClientData clientData;    /* Arbitrary value to pass to proc. */
  271.     struct Trace *nextPtr;    /* Next in list of traces for this interp. */
  272. } Trace;
  273.  
  274. /*
  275.  * The structure below defines a frame, which is a procedure invocation.
  276.  * These structures exist only while procedures are being executed, and
  277.  * provide a sort of call stack.
  278.  */
  279.  
  280. typedef struct CallFrame {
  281.     Tcl_HashTable varTable;    /* Hash table containing all of procedure's
  282.                  * local variables. */
  283.     int level;            /* Level of this procedure, for "uplevel"
  284.                  * purposes (i.e. corresponds to nesting of
  285.                  * callerVarPtr's, not callerPtr's).  1 means
  286.                  * outer-most procedure, 0 means top-level. */
  287.     int argc;            /* This and argv below describe name and
  288.                  * arguments for this procedure invocation. */
  289.     char **argv;        /* Array of arguments. */
  290.     struct CallFrame *callerPtr;
  291.                 /* Value of interp->framePtr when this
  292.                  * procedure was invoked (i.e. next in
  293.                  * stack of all active procedures). */
  294.     struct CallFrame *callerVarPtr;
  295.                 /* Value of interp->varFramePtr when this
  296.                  * procedure was invoked (i.e. determines
  297.                  * variable scoping within caller;  same
  298.                  * as callerPtr unless an "uplevel" command
  299.                  * or something equivalent was active in
  300.                  * the caller). */
  301. } CallFrame;
  302.  
  303. /*
  304.  * The structure below defines one history event (a previously-executed
  305.  * command that can be re-executed in whole or in part).
  306.  */
  307.  
  308. typedef struct {
  309.     char *command;        /* String containing previously-executed
  310.                  * command. */
  311.     int bytesAvl;        /* Total # of bytes available at *event (not
  312.                  * all are necessarily in use now). */
  313. } HistoryEvent;
  314.  
  315. /*
  316.  *----------------------------------------------------------------
  317.  * Data structures related to history.   These are used primarily
  318.  * in tclHistory.c
  319.  *----------------------------------------------------------------
  320.  */
  321.  
  322. /*
  323.  * The structure below defines a pending revision to the most recent
  324.  * history event.  Changes are linked together into a list and applied
  325.  * during the next call to Tcl_RecordHistory.  See the comments at the
  326.  * beginning of tclHistory.c for information on revisions.
  327.  */
  328.  
  329. typedef struct HistoryRev {
  330.     int firstIndex;        /* Index of the first byte to replace in
  331.                  * current history event. */
  332.     int lastIndex;        /* Index of last byte to replace in
  333.                  * current history event. */
  334.     int newSize;        /* Number of bytes in newBytes. */
  335.     char *newBytes;        /* Replacement for the range given by
  336.                  * firstIndex and lastIndex. */
  337.     struct HistoryRev *nextPtr;    /* Next in chain of revisions to apply, or
  338.                  * NULL for end of list. */
  339. } HistoryRev;
  340.  
  341. /*
  342.  *----------------------------------------------------------------
  343.  * Data structures related to files.  These are used primarily in
  344.  * tclUnixUtil.c and tclUnixAZ.c.
  345.  *----------------------------------------------------------------
  346.  */
  347.  
  348. /*
  349.  * The data structure below defines an open file (or connection to
  350.  * a process pipeline) as returned by the "open" command.
  351.  */
  352.  
  353. typedef struct OpenFile {
  354.     FILE *f;            /* Stdio file to use for reading and/or
  355.                  * writing. */
  356.     FILE *f2;            /* Normally NULL.  In the special case of
  357.                  * a command pipeline with pipes for both
  358.                  * input and output, this is a stdio file
  359.                  * to use for writing to the pipeline. */
  360.     int readable;        /* Non-zero means file may be read. */
  361.     int writable;        /* Non-zero means file may be written. */
  362.     int numPids;        /* If this is a connection to a process
  363.                  * pipeline, gives number of processes
  364.                  * in pidPtr array below;  otherwise it
  365.                  * is 0. */
  366.     int *pidPtr;        /* Pointer to malloc-ed array of child
  367.                  * process ids (numPids of them), or NULL
  368.                  * if this isn't a connection to a process
  369.                  * pipeline. */
  370.     int errorId;        /* File id of file that receives error
  371.                  * output from pipeline.  -1 means not
  372.                  * used (i.e. this is a normal file). */
  373. } OpenFile;
  374.  
  375. /*
  376.  *----------------------------------------------------------------
  377.  * This structure defines an interpreter, which is a collection of
  378.  * commands plus other state information related to interpreting
  379.  * commands, such as variable storage.  Primary responsibility for
  380.  * this data structure is in tclBasic.c, but almost every Tcl
  381.  * source file uses something in here.
  382.  *----------------------------------------------------------------
  383.  */
  384.  
  385. typedef struct Command {
  386.     Tcl_CmdProc *proc;        /* Procedure to process command. */
  387.     ClientData clientData;    /* Arbitrary value to pass to proc. */
  388.     Tcl_CmdDeleteProc *deleteProc;
  389.                 /* Procedure to invoke when deleting
  390.                  * command. */
  391. } Command;
  392.  
  393. #define CMD_SIZE(nameLength) ((unsigned) sizeof(Command) + nameLength - 3)
  394.  
  395. typedef struct Interp {
  396.  
  397.     /*
  398.      * Note:  the first three fields must match exactly the fields in
  399.      * a Tcl_Interp struct (see tcl.h).  If you change one, be sure to
  400.      * change the other.
  401.      */
  402.  
  403.     char *result;        /* Points to result returned by last
  404.                  * command. */
  405.     Tcl_FreeProc *freeProc;    /* Zero means result is statically allocated.
  406.                  * If non-zero, gives address of procedure
  407.                  * to invoke to free the result.  Must be
  408.                  * freed by Tcl_Eval before executing next
  409.                  * command. */
  410.     int errorLine;        /* When TCL_ERROR is returned, this gives
  411.                  * the line number within the command where
  412.                  * the error occurred (1 means first line). */
  413.     Tcl_HashTable commandTable;    /* Contains all of the commands currently
  414.                  * registered in this interpreter.  Indexed
  415.                  * by strings; values have type (Command *). */
  416.  
  417.     /*
  418.      * Information related to procedures and variables.  See tclProc.c
  419.      * and tclvar.c for usage.
  420.      */
  421.  
  422.     Tcl_HashTable globalTable;    /* Contains all global variables for
  423.                  * interpreter. */
  424.     int numLevels;        /* Keeps track of how many nested calls to
  425.                  * Tcl_Eval are in progress for this
  426.                  * interpreter.  It's used to delay deletion
  427.                  * of the table until all Tcl_Eval invocations
  428.                  * are completed. */
  429.     CallFrame *framePtr;    /* Points to top-most in stack of all nested
  430.                  * procedure invocations.  NULL means there
  431.                  * are no active procedures. */
  432.     CallFrame *varFramePtr;    /* Points to the call frame whose variables
  433.                  * are currently in use (same as framePtr
  434.                  * unless an "uplevel" command is being
  435.                  * executed).  NULL means no procedure is
  436.                  * active or "uplevel 0" is being exec'ed. */
  437.     ActiveVarTrace *activeTracePtr;
  438.                 /* First in list of active traces for interp,
  439.                  * or NULL if no active traces. */
  440.  
  441.     /*
  442.      * Information related to history:
  443.      */
  444.  
  445.     int numEvents;        /* Number of previously-executed commands
  446.                  * to retain. */
  447.     HistoryEvent *events;    /* Array containing numEvents entries
  448.                  * (dynamically allocated). */
  449.     int curEvent;        /* Index into events of place where current
  450.                  * (or most recent) command is recorded. */
  451.     int curEventNum;        /* Event number associated with the slot
  452.                  * given by curEvent. */
  453.     HistoryRev *revPtr;        /* First in list of pending revisions. */
  454.     char *historyFirst;        /* First char. of current command executed
  455.                  * from history module or NULL if none. */
  456.     int revDisables;        /* 0 means history revision OK;  > 0 gives
  457.                  * a count of number of times revision has
  458.                  * been disabled. */
  459.     char *evalFirst;        /* If TCL_RECORD_BOUNDS flag set, Tcl_Eval
  460.                  * sets this field to point to the first
  461.                  * char. of text from which the current
  462.                  * command came.  Otherwise Tcl_Eval sets
  463.                  * this to NULL. */
  464.     char *evalLast;        /* Similar to evalFirst, except points to
  465.                  * last character of current command. */
  466.  
  467.     /*
  468.      * Information used by Tcl_AppendResult to keep track of partial
  469.      * results.  See Tcl_AppendResult code for details.
  470.      */
  471.  
  472.     char *appendResult;        /* Storage space for results generated
  473.                  * by Tcl_AppendResult.  Malloc-ed.  NULL
  474.                  * means not yet allocated. */
  475.     int appendAvl;        /* Total amount of space available at
  476.                  * partialResult. */
  477.     int appendUsed;        /* Number of non-null bytes currently
  478.                  * stored at partialResult. */
  479.  
  480.     /*
  481.      * Information related to files.  See tclUnixAZ.c and tclUnixUtil.c
  482.      * for details.
  483.      */
  484.  
  485.     int numFiles;        /* Number of entries in filePtrArray
  486.                  * below.  0 means array hasn't been
  487.                  * created yet. */
  488.     OpenFile **filePtrArray;    /* Pointer to malloc-ed array of pointers
  489.                  * to information about open files.  Entry
  490.                  * N corresponds to the file with fileno N.
  491.                  * If an entry is NULL then the corresponding
  492.                  * file isn't open.  If filePtrArray is NULL
  493.                  * it means no files have been used, so even
  494.                  * stdin/stdout/stderr entries haven't been
  495.                  * setup yet. */
  496.     /*
  497.      * A cache of compiled regular expressions.  See TclCompileRegexp
  498.      * in tclUtil.c for details.
  499.      */
  500.  
  501. #define NUM_REGEXPS 5
  502.     char *patterns[NUM_REGEXPS];/* Strings corresponding to compiled
  503.                  * regular expression patterns.  NULL
  504.                  * means that this slot isn't used.
  505.                  * Malloc-ed. */
  506.     int patLengths[NUM_REGEXPS];/* Number of non-null characters in
  507.                  * corresponding entry in patterns.
  508.                  * -1 means entry isn't used. */
  509.     regexp *regexps[NUM_REGEXPS];
  510.                 /* Compiled forms of above strings.  Also
  511.                  * malloc-ed, or NULL if not in use yet. */
  512.  
  513.  
  514.     /*
  515.      * Miscellaneous information:
  516.      */
  517.  
  518.     int cmdCount;        /* Total number of times a command procedure
  519.                  * has been called for this interpreter. */
  520.     int noEval;            /* Non-zero means no commands should actually
  521.                  * be executed:  just parse only.  Used in
  522.                  * expressions when the result is already
  523.                  * determined. */
  524.     char *scriptFile;        /* NULL means there is no nested source
  525.                  * command active;  otherwise this points to
  526.                  * the name of the file being sourced (it's
  527.                  * not malloc-ed:  it points to an argument
  528.                  * to Tcl_EvalFile. */
  529.     int flags;            /* Various flag bits.  See below. */
  530.     Trace *tracePtr;        /* List of traces for this interpreter. */
  531.     char resultSpace[TCL_RESULT_SIZE+1];
  532.                 /* Static space for storing small results. */
  533. } Interp;
  534.  
  535. /*
  536.  * Flag bits for Interp structures:
  537.  *
  538.  * DELETED:        Non-zero means the interpreter has been deleted:
  539.  *            don't process any more commands for it, and destroy
  540.  *            the structure as soon as all nested invocations of
  541.  *            Tcl_Eval are done.
  542.  * ERR_IN_PROGRESS:    Non-zero means an error unwind is already in progress.
  543.  *            Zero means a command proc has been invoked since last
  544.  *            error occured.
  545.  * ERR_ALREADY_LOGGED:    Non-zero means information has already been logged
  546.  *            in $errorInfo for the current Tcl_Eval instance,
  547.  *            so Tcl_Eval needn't log it (used to implement the
  548.  *            "error message log" command).
  549.  * ERROR_CODE_SET:    Non-zero means that Tcl_SetErrorCode has been
  550.  *            called to record information for the current
  551.  *            error.  Zero means Tcl_Eval must clear the
  552.  *            errorCode variable if an error is returned.
  553.  */
  554.  
  555. #define DELETED            1
  556. #define ERR_IN_PROGRESS        2
  557. #define ERR_ALREADY_LOGGED    4
  558. #define ERROR_CODE_SET        8
  559.  
  560. /*
  561.  *----------------------------------------------------------------
  562.  * Data structures related to command parsing.   These are used in
  563.  * tclParse.c and its clients.
  564.  *----------------------------------------------------------------
  565.  */
  566.  
  567. /*
  568.  * The following data structure is used by various parsing procedures
  569.  * to hold information about where to store the results of parsing
  570.  * (e.g. the substituted contents of a quoted argument, or the result
  571.  * of a nested command).  At any given time, the space available
  572.  * for output is fixed, but a procedure may be called to expand the
  573.  * space available if the current space runs out.
  574.  */
  575.  
  576. typedef struct ParseValue {
  577.     char *buffer;        /* Address of first character in
  578.                  * output buffer. */
  579.     char *next;            /* Place to store next character in
  580.                  * output buffer. */
  581.     char *end;            /* Address of the last usable character
  582.                  * in the buffer. */
  583.     void (*expandProc) _ANSI_ARGS_((struct ParseValue *pvPtr, int needed));
  584.                 /* Procedure to call when space runs out;
  585.                  * it will make more space. */
  586.     ClientData clientData;    /* Arbitrary information for use of
  587.                  * expandProc. */
  588. } ParseValue;
  589.  
  590. /*
  591.  * A table used to classify input characters to assist in parsing
  592.  * Tcl commands.  The table should be indexed with a signed character
  593.  * using the CHAR_TYPE macro.  The character may have a negative
  594.  * value.
  595.  */
  596.  
  597. extern char tclTypeTable[];
  598. #define CHAR_TYPE(c) (tclTypeTable+128)[c]
  599.  
  600. /*
  601.  * Possible values returned by CHAR_TYPE:
  602.  *
  603.  * TCL_NORMAL -        All characters that don't have special significance
  604.  *            to the Tcl language.
  605.  * TCL_SPACE -        Character is space, tab, or return.
  606.  * TCL_COMMAND_END -    Character is newline or null or semicolon or
  607.  *            close-bracket.
  608.  * TCL_QUOTE -        Character is a double-quote.
  609.  * TCL_OPEN_BRACKET -    Character is a "[".
  610.  * TCL_OPEN_BRACE -    Character is a "{".
  611.  * TCL_CLOSE_BRACE -    Character is a "}".
  612.  * TCL_BACKSLASH -    Character is a "\".
  613.  * TCL_DOLLAR -        Character is a "$".
  614.  */
  615.  
  616. #define TCL_NORMAL        0
  617. #define TCL_SPACE        1
  618. #define TCL_COMMAND_END        2
  619. #define TCL_QUOTE        3
  620. #define TCL_OPEN_BRACKET    4
  621. #define TCL_OPEN_BRACE        5
  622. #define TCL_CLOSE_BRACE        6
  623. #define TCL_BACKSLASH        7
  624. #define TCL_DOLLAR        8
  625.  
  626. /*
  627.  * Additional flags passed to Tcl_Eval.  See tcl.h for other flags to
  628.  * Tcl_Eval;  these ones are only used internally by Tcl.
  629.  *
  630.  * TCL_RECORD_BOUNDS    Tells Tcl_Eval to record information in the
  631.  *            evalFirst and evalLast fields for each command
  632.  *            executed directly from the string (top-level
  633.  *            commands and those from command substitution).
  634.  */
  635.  
  636. #define TCL_RECORD_BOUNDS    0x100
  637.  
  638. /*
  639.  * Maximum number of levels of nesting permitted in Tcl commands.
  640.  */
  641.  
  642. #define MAX_NESTING_DEPTH    100
  643.  
  644. /*
  645.  * Variables shared among Tcl modules but not used by the outside
  646.  * world:
  647.  */
  648.  
  649. extern char *        tclRegexpError;
  650.  
  651. /*
  652.  *----------------------------------------------------------------
  653.  * Procedures shared among Tcl modules but not used by the outside
  654.  * world:
  655.  *----------------------------------------------------------------
  656.  */
  657.  
  658. extern void        panic();
  659. extern regexp *        TclCompileRegexp _ANSI_ARGS_((Tcl_Interp *interp,
  660.                 char *string));
  661. extern void        TclCopyAndCollapse _ANSI_ARGS_((int count, char *src,
  662.                 char *dst));
  663. extern void        TclDeleteVars _ANSI_ARGS_((Interp *iPtr,
  664.                 Tcl_HashTable *tablePtr));
  665. extern void        TclExpandParseValue _ANSI_ARGS_((ParseValue *pvPtr,
  666.                 int needed));
  667. extern int        TclFindElement _ANSI_ARGS_((Tcl_Interp *interp,
  668.                 char *list, char **elementPtr, char **nextPtr,
  669.                 int *sizePtr, int *bracePtr));
  670. extern Proc *        TclFindProc _ANSI_ARGS_((Interp *iPtr,
  671.                 char *procName));
  672. extern int        TclGetFrame _ANSI_ARGS_((Tcl_Interp *interp,
  673.                 char *string, CallFrame **framePtrPtr));
  674. extern int        TclGetListIndex _ANSI_ARGS_((Tcl_Interp *interp,
  675.                 char *string, int *indexPtr));
  676. extern int        TclGetOpenFile _ANSI_ARGS_((Tcl_Interp *interp,
  677.                 char *string, OpenFile **filePtrPtr));
  678. extern Proc *        TclIsProc _ANSI_ARGS_((Command *cmdPtr));
  679. extern void        TclMakeFileTable _ANSI_ARGS_((Interp *iPtr,
  680.                 int index));
  681. extern int        TclParseBraces _ANSI_ARGS_((Tcl_Interp *interp,
  682.                 char *string, char **termPtr, ParseValue *pvPtr));
  683. extern int        TclParseNestedCmd _ANSI_ARGS_((Tcl_Interp *interp,
  684.                 char *string, int flags, char **termPtr,
  685.                 ParseValue *pvPtr));
  686. extern int        TclParseQuotes _ANSI_ARGS_((Tcl_Interp *interp,
  687.                 char *string, int termChar, int flags,
  688.                 char **termPtr, ParseValue *pvPtr));
  689. extern int        TclParseWords _ANSI_ARGS_((Tcl_Interp *interp,
  690.                 char *string, int flags, int maxWords,
  691.                 char **termPtr, int *argcPtr, char **argv,
  692.                 ParseValue *pvPtr));
  693. extern void        TclSetupEnv _ANSI_ARGS_((Tcl_Interp *interp));
  694. extern char *        TclWordEnd _ANSI_ARGS_((char *start, int nested));
  695.  
  696. /*
  697.  *----------------------------------------------------------------
  698.  * Command procedures in the generic core:
  699.  *----------------------------------------------------------------
  700.  */
  701.  
  702. extern int    Tcl_AppendCmd _ANSI_ARGS_((ClientData clientData,
  703.             Tcl_Interp *interp, int argc, char **argv));
  704. extern int    Tcl_ArrayCmd _ANSI_ARGS_((ClientData clientData,
  705.             Tcl_Interp *interp, int argc, char **argv));
  706. extern int    Tcl_BreakCmd _ANSI_ARGS_((ClientData clientData,
  707.             Tcl_Interp *interp, int argc, char **argv));
  708. extern int    Tcl_CaseCmd _ANSI_ARGS_((ClientData clientData,
  709.             Tcl_Interp *interp, int argc, char **argv));
  710. extern int    Tcl_CatchCmd _ANSI_ARGS_((ClientData clientData,
  711.             Tcl_Interp *interp, int argc, char **argv));
  712. extern int    Tcl_ConcatCmd _ANSI_ARGS_((ClientData clientData,
  713.             Tcl_Interp *interp, int argc, char **argv));
  714. extern int    Tcl_ContinueCmd _ANSI_ARGS_((ClientData clientData,
  715.             Tcl_Interp *interp, int argc, char **argv));
  716. extern int    Tcl_ErrorCmd _ANSI_ARGS_((ClientData clientData,
  717.             Tcl_Interp *interp, int argc, char **argv));
  718. extern int    Tcl_EvalCmd _ANSI_ARGS_((ClientData clientData,
  719.             Tcl_Interp *interp, int argc, char **argv));
  720. extern int    Tcl_ExprCmd _ANSI_ARGS_((ClientData clientData,
  721.             Tcl_Interp *interp, int argc, char **argv));
  722. extern int    Tcl_ForCmd _ANSI_ARGS_((ClientData clientData,
  723.             Tcl_Interp *interp, int argc, char **argv));
  724. extern int    Tcl_ForeachCmd _ANSI_ARGS_((ClientData clientData,
  725.             Tcl_Interp *interp, int argc, char **argv));
  726. extern int    Tcl_FormatCmd _ANSI_ARGS_((ClientData clientData,
  727.             Tcl_Interp *interp, int argc, char **argv));
  728. extern int    Tcl_GlobalCmd _ANSI_ARGS_((ClientData clientData,
  729.             Tcl_Interp *interp, int argc, char **argv));
  730. extern int    Tcl_HistoryCmd _ANSI_ARGS_((ClientData clientData,
  731.             Tcl_Interp *interp, int argc, char **argv));
  732. extern int    Tcl_IfCmd _ANSI_ARGS_((ClientData clientData,
  733.             Tcl_Interp *interp, int argc, char **argv));
  734. extern int    Tcl_IncrCmd _ANSI_ARGS_((ClientData clientData,
  735.             Tcl_Interp *interp, int argc, char **argv));
  736. extern int    Tcl_InfoCmd _ANSI_ARGS_((ClientData clientData,
  737.             Tcl_Interp *interp, int argc, char **argv));
  738. extern int    Tcl_JoinCmd _ANSI_ARGS_((ClientData clientData,
  739.             Tcl_Interp *interp, int argc, char **argv));
  740. extern int    Tcl_LappendCmd _ANSI_ARGS_((ClientData clientData,
  741.             Tcl_Interp *interp, int argc, char **argv));
  742. extern int    Tcl_LindexCmd _ANSI_ARGS_((ClientData clientData,
  743.             Tcl_Interp *interp, int argc, char **argv));
  744. extern int    Tcl_LinsertCmd _ANSI_ARGS_((ClientData clientData,
  745.             Tcl_Interp *interp, int argc, char **argv));
  746. extern int    Tcl_LlengthCmd _ANSI_ARGS_((ClientData clientData,
  747.             Tcl_Interp *interp, int argc, char **argv));
  748. extern int    Tcl_ListCmd _ANSI_ARGS_((ClientData clientData,
  749.             Tcl_Interp *interp, int argc, char **argv));
  750. extern int    Tcl_LrangeCmd _ANSI_ARGS_((ClientData clientData,
  751.             Tcl_Interp *interp, int argc, char **argv));
  752. extern int    Tcl_LreplaceCmd _ANSI_ARGS_((ClientData clientData,
  753.             Tcl_Interp *interp, int argc, char **argv));
  754. extern int    Tcl_LsearchCmd _ANSI_ARGS_((ClientData clientData,
  755.             Tcl_Interp *interp, int argc, char **argv));
  756. extern int    Tcl_LsortCmd _ANSI_ARGS_((ClientData clientData,
  757.             Tcl_Interp *interp, int argc, char **argv));
  758. extern int    Tcl_ProcCmd _ANSI_ARGS_((ClientData clientData,
  759.             Tcl_Interp *interp, int argc, char **argv));
  760. extern int    Tcl_RegexpCmd _ANSI_ARGS_((ClientData clientData,
  761.             Tcl_Interp *interp, int argc, char **argv));
  762. extern int    Tcl_RegsubCmd _ANSI_ARGS_((ClientData clientData,
  763.             Tcl_Interp *interp, int argc, char **argv));
  764. extern int    Tcl_RenameCmd _ANSI_ARGS_((ClientData clientData,
  765.             Tcl_Interp *interp, int argc, char **argv));
  766. extern int    Tcl_ReturnCmd _ANSI_ARGS_((ClientData clientData,
  767.             Tcl_Interp *interp, int argc, char **argv));
  768. extern int    Tcl_ScanCmd _ANSI_ARGS_((ClientData clientData,
  769.             Tcl_Interp *interp, int argc, char **argv));
  770. extern int    Tcl_SetCmd _ANSI_ARGS_((ClientData clientData,
  771.             Tcl_Interp *interp, int argc, char **argv));
  772. extern int    Tcl_SplitCmd _ANSI_ARGS_((ClientData clientData,
  773.             Tcl_Interp *interp, int argc, char **argv));
  774. extern int    Tcl_StringCmd _ANSI_ARGS_((ClientData clientData,
  775.             Tcl_Interp *interp, int argc, char **argv));
  776. extern int    Tcl_TraceCmd _ANSI_ARGS_((ClientData clientData,
  777.             Tcl_Interp *interp, int argc, char **argv));
  778. extern int    Tcl_UnsetCmd _ANSI_ARGS_((ClientData clientData,
  779.             Tcl_Interp *interp, int argc, char **argv));
  780. extern int    Tcl_UplevelCmd _ANSI_ARGS_((ClientData clientData,
  781.             Tcl_Interp *interp, int argc, char **argv));
  782. extern int    Tcl_UpvarCmd _ANSI_ARGS_((ClientData clientData,
  783.             Tcl_Interp *interp, int argc, char **argv));
  784. extern int    Tcl_WhileCmd _ANSI_ARGS_((ClientData clientData,
  785.             Tcl_Interp *interp, int argc, char **argv));
  786. extern int    Tcl_Cmd _ANSI_ARGS_((ClientData clientData,
  787.             Tcl_Interp *interp, int argc, char **argv));
  788. extern int    Tcl_Cmd _ANSI_ARGS_((ClientData clientData,
  789.             Tcl_Interp *interp, int argc, char **argv));
  790.  
  791. /*
  792.  *----------------------------------------------------------------
  793.  * Command procedures in the UNIX core:
  794.  *----------------------------------------------------------------
  795.  */
  796.  
  797. extern int    Tcl_CdCmd _ANSI_ARGS_((ClientData clientData,
  798.             Tcl_Interp *interp, int argc, char **argv));
  799. extern int    Tcl_CloseCmd _ANSI_ARGS_((ClientData clientData,
  800.             Tcl_Interp *interp, int argc, char **argv));
  801. extern int    Tcl_EofCmd _ANSI_ARGS_((ClientData clientData,
  802.             Tcl_Interp *interp, int argc, char **argv));
  803. extern int    Tcl_ExecCmd _ANSI_ARGS_((ClientData clientData,
  804.             Tcl_Interp *interp, int argc, char **argv));
  805. extern int    Tcl_ExitCmd _ANSI_ARGS_((ClientData clientData,
  806.             Tcl_Interp *interp, int argc, char **argv));
  807. extern int    Tcl_FileCmd _ANSI_ARGS_((ClientData clientData,
  808.             Tcl_Interp *interp, int argc, char **argv));
  809. extern int    Tcl_FlushCmd _ANSI_ARGS_((ClientData clientData,
  810.             Tcl_Interp *interp, int argc, char **argv));
  811. extern int    Tcl_GetsCmd _ANSI_ARGS_((ClientData clientData,
  812.             Tcl_Interp *interp, int argc, char **argv));
  813. extern int    Tcl_GlobCmd _ANSI_ARGS_((ClientData clientData,
  814.             Tcl_Interp *interp, int argc, char **argv));
  815. extern int    Tcl_OpenCmd _ANSI_ARGS_((ClientData clientData,
  816.             Tcl_Interp *interp, int argc, char **argv));
  817. extern int    Tcl_PutsCmd _ANSI_ARGS_((ClientData clientData,
  818.             Tcl_Interp *interp, int argc, char **argv));
  819. extern int    Tcl_PwdCmd _ANSI_ARGS_((ClientData clientData,
  820.             Tcl_Interp *interp, int argc, char **argv));
  821. extern int    Tcl_ReadCmd _ANSI_ARGS_((ClientData clientData,
  822.             Tcl_Interp *interp, int argc, char **argv));
  823. extern int    Tcl_SeekCmd _ANSI_ARGS_((ClientData clientData,
  824.             Tcl_Interp *interp, int argc, char **argv));
  825. extern int    Tcl_SourceCmd _ANSI_ARGS_((ClientData clientData,
  826.             Tcl_Interp *interp, int argc, char **argv));
  827. extern int    Tcl_TellCmd _ANSI_ARGS_((ClientData clientData,
  828.             Tcl_Interp *interp, int argc, char **argv));
  829. extern int    Tcl_TimeCmd _ANSI_ARGS_((ClientData clientData,
  830.             Tcl_Interp *interp, int argc, char **argv));
  831.  
  832. #endif /* _TCLINT */
  833.